home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / hpgl2ps.zip / PS_MACRO.C < prev    next >
Text File  |  1989-08-08  |  5KB  |  123 lines

  1. ps_macros()
  2. {
  3.     printf("%%! PS-Adobe-1.0: For Apple LaserWriter\n");
  4.     printf("%% default font is 14 pt. Helvetica\n");
  5.     printf("/basefont {/Helvetica findfont 14 scalefont setfont} def\n");
  6.  
  7.     /*printf("/mm {72.27 mul 25.4 div} def\n");    Specify millimeters */
  8.     printf("/mm {72.0 mul 25.4 div} def\n");    /* Specify millimeters */
  9.  
  10.     printf("/M\n");                /* Move macro */
  11.     printf("{\n");
  12.     printf("    /Ymove exch def\n");
  13.     printf("    /Xmove exch def\n");
  14.     printf("    Xmove mm Ymove mm moveto\n");
  15.     printf("} def\n");
  16.  
  17.     printf("/R\n");                /* Relative move macro */
  18.     printf("{\n");
  19.     printf("    /Yrmove exch def\n");
  20.     printf("    /Xrmove exch def\n");
  21.     printf("    Xrmove mm Yrmove mm rmoveto\n");
  22.     printf("} def\n");
  23.  
  24.     printf("/D\n");                /* Draw macro */
  25.     printf("{\n");
  26.     printf("    /Ydraw exch def\n");
  27.     printf("    /Xdraw exch def\n");
  28.     printf("    Xdraw mm Ydraw mm lineto\n");
  29.     printf("} def\n");
  30.  
  31.     printf("/I\n");                /* Relative draw  macro */
  32.     printf("{\n");
  33.     printf("    /Yrdraw exch def\n");
  34.     printf("    /Xrdraw exch def\n");
  35.     printf("    Xrdraw mm Yrdraw mm rlineto\n");
  36.     printf("} def\n");
  37.     /*
  38.      *        Procedure to change font and size of font
  39.      *        ---->   font size Font    <----
  40.      */
  41.     printf("/Font\n");
  42.     printf("{\n");
  43.     printf("    /Height exch def\n");
  44.     printf("    /FontName exch def\n");
  45.     printf("    FontName findfont Height mm scalefont setfont\n");
  46.     printf("} def\n");
  47.     /*
  48.      *        Procedure to change font, width, slant and height
  49.      *        ---->   font width height slant DefFont    <----
  50.      *
  51.      *    Note: slant = height * tan( slant_angle )
  52.      */
  53.     printf("/DefFont\n");
  54.     printf("{\n");
  55.     printf("    /Slant exch def\n");
  56.     printf("    /Height exch def\n");
  57.     printf("    /Width exch def\n");
  58.     printf("    /FontName exch def\n");
  59.     printf("    FontName findfont [ Width mm 0 Slant mm Height mm 0 0] makefont setfont\n");
  60.     printf("} def\n");
  61.     /*
  62.      *        General Text Layout Procedure
  63.      *        ---->   x y pos_num angle (text) Text    <----
  64.      */
  65.     printf("/Text\n");
  66.     printf("{\n");
  67.     printf("    /String exch def\n");
  68.     printf("    /Angle exch def\n");
  69.     printf("    /Position exch def\n");
  70.     printf("    /Ymove exch def\n");
  71.     printf("    /Xmove exch def\n");
  72.     printf("    Position 1 lt {/hpf 0 def /lpf 0 def} if\n");
  73.     printf("    Position 1 eq {/hpf 0 def /lpf 0 def} if\n");
  74.     printf("    Position 2 eq {/hpf 0 def /lpf 0.5 def} if\n");
  75.     printf("    Position 3 eq {/hpf 0 def /lpf 1 def} if\n");
  76.     printf("    Position 4 eq {/hpf 0.5 def /lpf 0 def} if\n");
  77.     printf("    Position 5 eq {/hpf 0.5 def /lpf 0.5 def} if\n");
  78.     printf("    Position 6 eq {/hpf 0.5 def /lpf 1 def} if\n");
  79.     printf("    Position 7 eq {/hpf 1 def /lpf 0 def} if\n");
  80.     printf("    Position 8 eq {/hpf 1 def /lpf 0.5 def} if\n");
  81.     printf("    Position 9 eq {/hpf 1 def /lpf 1 def} if\n");
  82.     printf("    Position 9 gt {/hpf 1 def /lpf 1 def} if\n");
  83.     printf("    /StrLen String stringwidth pop lpf mul def\n");
  84.     printf("    /StrHt Height mm hpf mul def\n");
  85.     printf("    /Xdiff StrHt Angle sin mul StrLen Angle cos mul sub def\n");
  86.     printf("    /Ydiff StrHt Angle cos mul StrLen Angle sin mul add def\n");
  87.     printf("    Xmove mm Xdiff add Ymove mm Ydiff sub moveto\n");
  88.     printf("    gsave\n");
  89.     printf("        Angle rotate\n");
  90.     printf("        String show\n");
  91.     printf("    grestore\n");
  92.     printf("    /PosterOnly 0 def\n");
  93.     printf("} def\n");
  94.     /*
  95.      *        Ellipse and Circle procedure.
  96.      *  ---->   xcen ycen xrad yrad start_angle end_angle Ellipse   <----
  97.      */
  98.     printf("/EllipseDict 8 dict def\n");
  99.     printf("EllipseDict /mtrx matrix put\n");
  100.     printf("/Ellipse \n");
  101.     printf("{   EllipseDict begin\n");
  102.     printf("    /endangle exch def\n");
  103.     printf("    /startangle exch def\n");
  104.     printf("    /yradius exch def\n");
  105.     printf("    /xradius exch def\n");
  106.     printf("    /ycenter exch def\n");
  107.     printf("    /xcenter exch def\n");
  108.     printf("    /savematrix mtrx currentmatrix def\n");
  109.     printf("    xcenter mm ycenter mm translate\n");
  110.     printf("    xradius mm yradius mm div 1 scale\n");
  111.     printf("    newpath\n");
  112.     printf("        0 0 xradius mm startangle endangle arc\n");
  113.     printf("    stroke\n");
  114.     printf("    savematrix setmatrix\n");
  115.     printf("    end\n");
  116.     printf("} def\n");
  117.  
  118.     printf("basefont\n");        /* Set the default font */
  119.     printf("1 setlinecap\n");        /* Use round caps */
  120.     printf("1 setlinejoin\n");        /* Use round joins */
  121.     printf("3 setmiterlimit\n");    /* Bevel small angle miters */
  122. }
  123.